<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>灌水问题</title>
    <script>
      //定义变量保存当前储水量
      let total = 0
      //定义变量计算时间
      let min = 0
      //循环
      for (;;) {
        min++
        total += min - 3
        //注意: 桶中水的容量不会是负数
        if (total < 0) {
          total = 0
        }
        if (total >= 10) {
          break
        }
      }
      alert('一共消耗: ' + min + '分钟.')
    </script>
  </head>
  <body></body>
</html>
